
<!-- 列表 -->
<div class="list-div" id="listDiv">
<form action="__SELF__" method="post" class="form-inline">
	<table cellpadding="3" cellspacing="1" class="table table-hover">
		<thead style="background-color: skyblue;">
			<tr>
				<foreach name="gaData" item="v" key="k">
				<th >{$k}</th>
			</foreach>
				<th width="120">库存量</th>
				<th width="60">操作</th>
			</tr>
				</thead>
			<tbody>
					<?php if($gnData): ?>
					<?php foreach($gnData as $k0 => $v0):?>
					<tr>
						<?php $gnCount = count($gaData)?>
						<?php foreach($gaData as $k => $v):
						?>
							<td>
								<select name="goods_attr_id[]">
									<option value="">请选择...</option>
										<?php foreach($v as $k1 => $v1):
										$_attr = explode(',',$v0['goods_attr_id']);
										if(in_array($v1['id'],$_attr))
										$select = 'selected =" selected "';
										else
										$select ="";
										?>
										<option <?php echo $select?> value="<?php echo $v1['id']?>"><?php echo $v1['attr_value']; ?></option>
									<?php endforeach?>
								</select>
							</td>
						<?php endforeach ?>
						<td><input name="goods_number[]" type="text" value="{$v0.goods_number}"/></td>
						<td><input class="form-control" type="button"  value="+" onclick="addNewTr(this);"/></td>
					</tr>
					<?php endforeach?>
					<?php else: ?>
					<tr>
						<?php $gnCount = count($gaData)?>
						<?php foreach($gaData as $k => $v):
						?>
						<td>
							<select name="goods_attr_id[]">
								<option value="">请选择...</option>
								<?php foreach($v as $k1 => $v1):
								?>
								<option value="<?php echo $v1['id']?>"><?php echo $v1['attr_value']; ?></option>
								<?php endforeach?>
							</select>
						</td>
						<?php endforeach ?>
						<td><input name="goods_number[]" type="text" value=""/></td>
						<td><input class="form-control" type="button"  value="+" onclick="addNewTr(this);"/></td>
					</tr>
					<?php endif?>
				<tr id="submit">
					<td align="center" colspan="<?php echo $gnCount+2; ?>">
					<input value="提交" type="submit"/>
					</td>
				</tr>
		</tbody>
	</table>
</form>
</div>
<script>
	function addNewTr( btn ) {
		var tr = $( btn ).parent().parent();
		if( $( btn ).val() == '+' ){
			var new_tr = tr.clone();
			new_tr.find( ':button' ).val( '-' );
			tr.after( new_tr );
		}else{
			tr.remove();
		}
	}
</script>

<script src="__PUBLIC__/Admin/Js/tron.js"></script>